package com.siegelion.section.home;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.siegelion.R;
import com.siegelion.plugin.MethodChannelPlugin;
import com.siegelion.section.base.BaseInitFragment;


import io.flutter.facade.Flutter;
import io.flutter.view.FlutterView;

public class HomeFragment extends BaseInitFragment {

    @Override
    protected int getLayoutId() {
        return R.layout.demo_fragment_discover;
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

        FlutterView flutterView = Flutter.createView(getActivity(),getLifecycle(),"home");
        MethodChannelPlugin.registerWith(flutterView);
        return flutterView;
        //创建引擎
//        FlutterEngine lFlutterEngine = new FlutterEngine(getContext());
//        //设置一些参数
//        lFlutterEngine.getNavigationChannel().setInitialRoute("my");
//        //设置消息通道
//        //setMessageChannel(lFlutterEngine);
//        //设置缓存
//        lFlutterEngine.getDartExecutor().executeDartEntrypoint(DartExecutor.DartEntrypoint.createDefault());
//        FlutterEngineCache.getInstance().put("test_engine", lFlutterEngine);
//        FlutterFragment lFlutterFragment = FlutterFragment
//                .withCachedEngine("test_engine")
//                .build();
//        lFlutterFragment.onCreateView(inflater,container,savedInstanceState);
//        return lFlutterFragment.getView();
    }
}
